<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="app" uri="/application" %>
<%@ taglib  prefix="s"  uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="/css/role.css" rel="stylesheet" type="text/css" />
<style type="text/css">

  .brand {border: 1px solid #ccc;border-radius: 3px;font-size: 13px;line-height: 40px;padding: 0.5em 0.6em;text-align: center;white-space: nowrap;}

</style>
</head>
<body>
<!-- title -->
<div class="right_title">
<div class="h"><span>运营中心-</span> </div>
</div>
<!-- title end -->
<div class="zdgl xz_pad" style="border:0px solid red;">
  <form action="/operator/save_cate_brand.shtml" name="pst" method="post">
  <div>
     商品分类：<select name="cate" id="position" onchange="ck_check(this);" style="width:300px;border: 1px solid #ccc;border-radius: 3px;height:32px;">
	        <option value="">请选择...</option>
	        <app:cons_select code="001"  type="tree"></app:cons_select>
      </select>
  </div>

  <br/>
  <div class="d_01">
        <div>
	        <c:forEach items="${list}" var="c">
	           <span class="brand"><input type="checkbox" name="brand" value="${c.code}" /> ${c.contsName}</span>
	        </c:forEach>
        </div>
  </div>

  <div class="clear0"></div>
  <div class="subd"><input type="button" value="保存分类品牌 " onclick="save_do()"  /></div>
  </form>
  <div id="boxId" style="position: absolute;background: red;display:none;"><span style="color:#fff;">正在加载...</span></div>
</div>
<!-- table end -->


</body>
</html>
<script type="text/javascript" src="/scripts/util.js"></script>
<script type="text/javascript" src="/scripts/xhr.js"/></script>
<script type="text/javascript" src="/scripts/head_search.js"/></script>
<script type="text/javascript" >
   function cg(id,th){
     var o = util.$(id);
     if(o){
       o.style.display=o.style.display=='none'?'':'none';
       th.className=o.style.display=='none'?'shi':'shiyi';
     }
   }
   function bcg(tag,id,th){
      var r = document.getElementsByTagName(tag);
      var nr = filterpid(r,id);
      util.each(nr,function(e,i){
         e.style.display=e.style.display=='none'?'':'none';
         (i==0)&&(th.className==e.style.display=='none'?'shi':'shiyi');
      })
   }
   function filterpid(r,id){
      var nr=[];
      util.each(r,function(e){
         if(e.getAttribute('parent')==id){
            nr.push(e);
         }
      });
      return nr;
   }
   
  function ca(id,th,nm){
     var nm = nm||"ids";
     var r = filterCk(document.getElementsByName(nm),id);
     util.each(r,function(e){
       e.checked=th.checked;
       ca(e.value,e);
     });
  }
  function ac(id,nm){
    var nm = nm||"ids";
    var r = filterCk(document.getElementsByName(nm),id);
    var b = false;
    util.each(r,function(e){
        if(e.checked){
          b=true;
          return 1;
        }
    });
    var t = util.$(id+'_ck');
    t&&(t.checked=b);
    t&&(nm=="operIds")&&(ac(t.getAttribute("pid")));
  }
  function filterCk(list,id){
    var r=[];
    util.each(list,function(e){
      (e.getAttribute('pid')==id)&&r.push(e);
    });
    return r;
  }
  function ck_check(th){
      if(th.value!=""){
         util.dusk_div("boxId");
         function callback(d){
            util.close_dusk("boxId");
            var o = eval("("+d+")");
            checkDo("brand",o.regexp||"");
         }
         new xhr("/operator/load_cate_brand.shtml",callback).setParameter("cate",th.value).execute();
      }
  }
  function checkDo(name,reg){
     var r = document.getElementsByName(name);
     var regxp = new RegExp("^("+reg+")$");
     util.each(r,function(e){
        e.checked = regxp.test(e.value);
     })
  }
  function save_do(){
    if(confirm("确定保存分类品牌?")){
       var position = util.$('position');
       if(position&&position.value!=""){
         document.pst.submit();
       }else{
         alert("请选择一设置分类!");
       }
    }
  }
  
</script>


